home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F25764_AlternatingCols.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-10-04  |  1.8 KB  |  54 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- ===========================================================
  3.   Category:       TableFormatting
  4.   Sub-category:   AlternatingCols
  5.   Author:         David Silverlight
  6.                   HeadGeek@xmlpitstop.com
  7.   Created:        2001-05-16
  8.   Description:-
  9.     This XSLT file will display rows of data in an HTML table,
  10.     displaying every alternate column in a different color.
  11. ================================================================ -->
  12. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  13.     <xsl:output method="html"/>
  14.     <xsl:template match="/">
  15.  
  16.         <STYLE>
  17.         H1: {COLOR: blue FONT-FAMILY: Arial; }
  18.         SubTotal {COLOR: green;  FONT-FAMILY: Arial}
  19.         BODY {COLOR: blue; FONT-FAMILY: Arial; FONT-SIZE: 8pt;}
  20.         TD.clsOdd { background-color: beige; }
  21.         TD.clsEven { background-color: #cccccc; }
  22.         </STYLE>
  23.         
  24.         <H2>Customer Listing (in Alternating colors) </H2>
  25.         <table border="1" cellPadding="2" cellSpacing="1">
  26.             <tr borderColorDark="#fcfcfc" borderColorLight="#999999">
  27.                 <xsl:for-each select="//customers/customer[1]/@*">
  28.                     <th>
  29.                         <xsl:value-of select="name()"/>
  30.                     </th>
  31.                 </xsl:for-each>
  32.             </tr>
  33.             <xsl:for-each select="/customers/customer">
  34.                 <tr>
  35.                     <xsl:for-each select="@*">
  36.                         <td>
  37.                             <xsl:choose>
  38.                                 <xsl:when test="position() mod 2 = 1">
  39.                                     <xsl:attribute name="class">clsOdd</xsl:attribute>
  40.                                 </xsl:when>
  41.                                 <xsl:otherwise>
  42.                                     <xsl:attribute name="class">clsEven</xsl:attribute>
  43.                                 </xsl:otherwise>
  44.                             </xsl:choose>
  45.                             <xsl:value-of select="."/>
  46.                         </td>
  47.                     </xsl:for-each>
  48.                 </tr>
  49.             </xsl:for-each>
  50.         </table>
  51.         <H3>Total Customers <xsl:value-of select="count(customers/customer)"/>
  52.         </H3>
  53.     </xsl:template>
  54. </xsl:stylesheet>